import { Component, OnInit } from '@angular/core';
import { NewService } from 'src/app/services/news.service';
import * as constants from '../../../providers/Constants'
import { ToastService } from 'src/app/providers/toast/toast.service';
import { Utils } from 'src/app/providers/Utils';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-my-message',
  templateUrl: './my-message.page.html',
  styleUrls: ['./my-message.page.scss'],
})
export class MyMessagePage implements OnInit {

  array:any=[];
  constructor(private mNewService:NewService,private toast:ToastService,private nav:NavController) { }

  ngOnInit() {
    this.query();
  }
  query(){
    this.mNewService.getSystemMsg({
      param:'3',
    }).subscribe(res => {
      if (res.retCode == '000000') {
        this.array=res.array;
      } else if (constants.errCode[res.retCode]) {
        if (constants.errCode[res.retCode] != '0') {           this.toast.show(constants.errCode[res.retCode]);         }
       } else if (res.retMsg) {
         this.toast.show(res.retMsg);
       } else {
         this.toast.show("exception service routine");
       }
    })
  }
  strFormatData(str){
    return Utils.strFormatData(str);
  }

  onPay(){
    this.nav.navigateForward('system-message',{
      queryParams:{
        type:'1',
      }
    });
  }
}
